import CryptoJS from "crypto-js";

const key = import.meta.env.VITE_ENCRYPTION_KEY;

export function encryptData(data: string) {
    return CryptoJS.AES.encrypt(JSON.stringify(data), key).toString();
}

export function decryptData(ciphertext: string) {
    const bytes = CryptoJS.AES.decrypt(ciphertext, key);
    return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
}
